package cn.com.bluemoon.daps.sync.service;

import cn.com.bluemoon.daps.common.domain.UserInfoHolder;
import cn.com.bluemoon.daps.common.enums.SyncStatus;
import cn.com.bluemoon.daps.common.enums.SyncToEnv;
import cn.com.bluemoon.daps.common.mp.IBmService;
import cn.com.bluemoon.daps.sync.core.sync.GlobalConfig;
import cn.com.bluemoon.daps.sync.entity.DapSyncProdEnvTaskDetail;
import cn.com.bluemoon.daps.sync.vo.syncmanage.SyncTableEnvAndRealDdlParam;
import cn.com.bluemoon.daps.sync.vo.syncmanage.SyncTableParam;

import java.util.List;
import java.util.Optional;

/**
 * <p>
 * 发布同步单号数据任务-明细表 服务类
 * </p>
 *
 * @author admin
 * @since 2021-06-17
 */
public interface DapSyncProdEnvTaskDetailService extends IBmService<DapSyncProdEnvTaskDetail> {
    /**
     * 根据任务id获取任务明细列表
     *
     * @param taskId 任务id
     * @return 列表
     */
    List<DapSyncProdEnvTaskDetail> findTaskDetailsByTaskId(String taskId);

    List<DapSyncProdEnvTaskDetail> findSyncTasks(String taskId, GlobalConfig globalConfig);

    boolean updateStatusByParam(SyncTableEnvAndRealDdlParam param, SyncToEnv syncToEnv, UserInfoHolder.UserInfo userInfo);

    Optional<DapSyncProdEnvTaskDetail> queryOneByParam(SyncTableParam param);

    /**
     * 更新状态syncWait
     * @param taskId 认为id
     * @param syncToEnv 环境
     * @param syncWait 状态
     */
    void updateSyncStatusByTaskIdAndSyncEnvAndSyncStatus(String taskId, SyncToEnv syncToEnv, SyncStatus syncWait);

    void updateTableSyncFailOnSandbox(String taskId, boolean sandboxSyncFail);

    /**
     * 更新任务下的明细日志（追加）
     */
    void updateSyncLogContent(String taskId, SyncToEnv syncToEnv, String logContent);
}
